<html><head><title>Pseudotypes</title></head>
<body bgcolor="#EFF1F0" link="#3A3966" vlink="#000000" alink="#000000">
<font face="Verdana, sans-serif" size="2"><p align="center"><b><font size="5">Pseudotypes</font></b></p>

<b>Description</b><br><blockquote>


For advanced programmers. The pseudotypes are a way to ease the programming when dealing with 
external libraries which need datatypes that are not internally supported by PureBasic. In this 
case, it is possible to use the predefined pseudotype which will do the appropriate conversion 
on the fly, without extra work. As they are not 'real' types, the chosen naming scheme is explicitly 
different: a 'p-' prefix (for 'pseudo') is part of the type name. The available pseudotypes are: 
<pre><font face="Courier New, Courier, mono"size="2">  p-ascii: acts as a string type, but will always convert the string to ascii before
           calling the function, even when the program is compiled in <a href="unicode.html">unicode</a> mode. 
           It is very useful when accessing a shared library which doesn't have unicode 
           support in an unicode program for example.
           
  p-utf8: acts as a string type, but will always convert the string to utf8 before calling the
          function. It is very useful when accessing a shared library which needs its <a href="unicode.html">unicode</a>
          string be passed as UTF8 instead of ascii or unicode strings.

  p-bstr: acts as a string type, but will always convert the string to bstr before calling the
          function. It is very useful when accessing a shared library which needs bstr parameters,
          like COM components.

  p-unicode: acts as a string type, but will always convert the string to <a href="unicode.html">unicode</a> before
             calling the function, even when the program is compiled in ascii mode. 
             It is very useful when accessing a shared library which only supports unicode
             in an ascii program for example.

  p-variant: acts as a numeric type, will adjust the function call to use the variant parameter
             correctly. It is very useful when accessing a shared library which needs 'variant' parameters,
             like COM components.
</font></pre>

The pseudotypes can only be used with <a href="prototypes.html">prototypes</a>, <a href="interfaces.html">interfaces</a> 
and <a href="import_endimport.html">imported</a> functions. The pseudotypes does the appropriate 
conversion only if it is necessary: for example using a 'p-ascii' pseudotype in an ascii compiled program makes 
no difference with regular string type. 

</blockquote><p><b>Example</b></p><blockquote>


<pre><font face="Courier New, Courier, mono"size="2">  <b><font color="#3A3966">Import</font></b> &quot;User32.lib&quot;
   
    <font color="#3A3966">; We use the 'p-unicode' pseudotype for the string parameters, as</font>
    <font color="#3A3966">; MessageBoxW() is an unicode only function. The compiler will </font>
    <font color="#3A3966">; automatically converts the strings to unicode when needed.</font>
    <font color="#3A3966">;</font>
<font color="#3A3966">    MessageBoxW</font>(Window.i, Body.p-unicode, Title.p-unicode, Flags.i = 0)
                                                  
  <b><font color="#3A3966">EndImport</font></b>
  
  <font color="#3A3966">; It will work correctly in ascii and in unicode mode, even if the API is unicode</font>
  <font color="#3A3966">; only as the compiler will take care of the conversion itself.</font>
  <font color="#3A3966">;</font>
<font color="#3A3966">  MessageBoxW</font>(0, &quot;Hello&quot;, &quot;World&quot;)
    
</font></pre>



</body></html>